﻿using Microsoft.VisualStudio.TestTools.UnitTesting;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Text;
using T.FAS.Runtime.Base.Dao;
using T.FAS.Runtime.Base.Entity;
using T.FAS.Runtime.Base.Service;
using System.Linq;

namespace T.FAS.Runtime.Base.UnitTest
{

    [TestClass]
    public class TestFunctionTree
    {
        FunctionTreeService functionTreeService = new FunctionTreeService();
        /// <summary>
        /// 获取关键应用名称
        /// </summary>
        /// <param name="appId"></param>
        /// <returns></returns>
        [TestMethod]
        public void GetApplicationSortName()
        {
            var appId = functionTreeService.GetApplicationSortName("edd457b3-8adc-477c-abbb-fe52060e6a6d", "5786793F-7CDF-4A17-BBE8-B073D2081888");
            Assert.AreEqual("MGEM", appId);
        }
        /// <summary>
        /// 获取产品版本下关键应用
        /// </summary>
        /// <returns></returns>
        [TestMethod]
        public void GetApplications()
        {
            string productVersionID = "152F8657-4865-4FF9-8CF4-B8E774C8B95E";
            string subSystemID = "03477659-fced-464c-af82-d7ecd0a8f4bb";
            Dictionary<string, string> param = new Dictionary<string, string>();
            param.Add("productVersionID", productVersionID);
            param.Add("subSystemID", subSystemID);
            string s = JsonConvert.SerializeObject(param);
            var apps = functionTreeService.GetApplications(productVersionID, subSystemID);
            Assert.IsNotNull(apps);
        }
        /// <summary>
        /// 获取关键应用下模块
        /// </summary>
        /// <returns></returns>
        [TestMethod]
        public void GetModules()
        {
            Function app = new Function { SubSystemID = "03477659-fced-464c-af82-d7ecd0a8f4bb", ApplicationID = "03477659-fced-464c-af82-d7ecd0a8f4bb", ProductVersionID = "152F8657-4865-4FF9-8CF4-B8E774C8B95E" };
            Dictionary<string, object> param = new Dictionary<string, object>();
            param.Add("app", app);
            string s = JsonConvert.SerializeObject(param);
            var apps = functionTreeService.GetModules(app);
            Assert.IsNotNull(apps);
        }
        /// <summary>
        /// 获取功能组名称
        /// </summary>
        /// <param name="groupID"></param>
        /// <returns></returns>
        [TestMethod]
        public void GetGroupName()
        {
            string productVersionID = "5786793F-7CDF-4A17-BBE8-B073D2081888";
            string groupID = "03DCD394-D9C8-4AB0-BFAB-18E00D7128AD";
            Dictionary<string, string> param = new Dictionary<string, string>();
            param.Add("productVersionID", productVersionID);
            param.Add("groupID", groupID);
            string s = JsonConvert.SerializeObject(param);
            string groupName = functionTreeService.GetGroupName(groupID, productVersionID);
            Assert.IsNotNull(groupName);
        }
        /// <summary>
        /// 弃用
        /// </summary>
        /// <returns></returns>
        [TestMethod]
        public void GetFunctionTree()
        {
            Assert.IsNotNull(functionTreeService.GetFunctionTree());
            Assert.IsNotNull(functionTreeService.GetMenuGroup(new Function()));
        }
    }
}
